package com.ucap.bbs.controller.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ucap.bbs.pojo.Module;
import com.ucap.bbs.service.IModuleService;

public class ModuleAction extends ActionSupport {
	
	private IModuleService moduleService;
	
	public void setModuleService(IModuleService moduleService) {
		this.moduleService = moduleService;
	}

	public String getModuleForIndex(){
		Module queryModule = new Module();
		queryModule.setPrtGuid("#");
		List<Module> listMax = this.moduleService.queryList(queryModule);
		ServletActionContext.getRequest().setAttribute("listMax", listMax);
		
		if(null!=listMax){
			for (int i = 0; i < listMax.size(); i++) {
				Module module = new Module();
				module.setPrtGuid(listMax.get(i).getGuid());
				List<Module> list = this.moduleService.queryList(module);
				ServletActionContext.getRequest().setAttribute("list"+i, list);
			}
		}
		return "bmdw";
	}
	
	private Module module = new Module();

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}
}
